﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Serialization;
using System.Globalization;

namespace QA_System
{
    // doc va xu ly cau hoi

    public class word_tagger
    {
        string text;
        string pos;
        public string Word_text
        {
            get { return text; }
            set { text = value; }
        }
        public string Word_pos
        {
            get { return pos; }
            set { pos = value; }
        }

        public word_tagger()
        {
            text = "";
            pos = "";
        }
        public word_tagger(string addtext, string addpos)
        {
            text = addtext;
            pos = addpos;
        }
    }

    public class sentence_tagger
    {
        private word_tagger[] sentence_tag;
        public sentence_tagger()
        {
            this.sentence_tag = new word_tagger[100];
            this.Creatsentence(100);

        }

        public sentence_tagger(int totalnode)
        {
            this.sentence_tag = new word_tagger[totalnode];
            this.Creatsentence(totalnode);

        }

        private void Creatsentence(int totalnode)
        {
            for (int i = 0; i < totalnode; i++) sentence_tag[i] = new word_tagger();
        }

        public int totalword()
        {
            int total = 0;
            for (int i = 0; i<sentence_tag.Length; i++)
                if (sentence_tag[i].Word_text != "") total = total + 1;
            return total;

        }

        public word_tagger this[int i]
        {
            get { return sentence_tag[i]; }
            set { sentence_tag[i] = value; }
        }

        public int Sentence_length
        {
            get { return sentence_tag.Length; }
        }
    }

    public class nodewait
    {
        private XmlNode node;
        private int mark_string;

        public nodewait()
        {
            node = null;
            mark_string = -1;
        }


        public nodewait(XmlNode xml_node, int mark)
        {
            node = xml_node;
            mark_string = mark;
        }
        public XmlNode node_content()
        {
            return node;
        }
        public int mark_word()
        {
            return mark_string;
        }

        public void set_mark_work()
        {
            mark_string = -1;
        }
        public void set_node(XmlNode xml_node, int mark)
        {
            node = xml_node;
            mark_string = mark;
        }
    }

    public class nodewaitlist
    {
        private nodewait[] node_wait_list;
        public nodewaitlist()
        {
            this.node_wait_list = new nodewait[30];
            this.Creatlist(30);

        }

        private void Creatlist(int totalnode)
        {
            for (int i = 0; i < totalnode; i++) node_wait_list[i] = new nodewait();
        }

        public int total_element()
        {
            int total = 0;
            for (int i = 0; i < 30; i++)
                if (node_wait_list[i].mark_word() != -1) total++;
            return total;

        }
        public nodewait this[int i]
        {
            get { return node_wait_list[i]; }
            set { node_wait_list[i] = value; }
        }

    }


    // mapping với CSDL

    public class Genrefield
    {
        private int _Gen_Id;

        private string _Kind;

        private string _Description;

        private bool _isDescriptionNull;

        public Genrefield()
        {
            _Gen_Id = 0;
            _Kind = "";
            _Description = "";
            _isDescriptionNull = true;
        }

        public Genrefield(int keyid, string wordid)
        {
            _Gen_Id = keyid;
            _Kind = wordid;
            _Description = "";
            _isDescriptionNull = true;
        }

        public Genrefield(int keyid, string wordid, string desc)
        {
            _Gen_Id = keyid;
            _Kind = wordid;
            _Description = desc;
            _isDescriptionNull = false;
        }

        public int Gen_ID
        {
            get { return _Gen_Id; }
            set { _Gen_Id = value; }
        }

        public string KIND
        {
            get { return _Kind; }
            set { _Kind = value; }
        }

        public string Description
        {
            get
            {
                if (_isDescriptionNull)
                {
                    throw new InvalidOperationException();
                }
                else return _Description;
            }
            set
            {
                _Description = value;
                _isDescriptionNull = false;
            }
        }

        public bool IsDescriptionNull
        {
            get { return _isDescriptionNull; }
            set { _isDescriptionNull = value; }
        }
    }

    public class Artistfield
    {
        private int _Art_Id;

        private string _Name;

        private DateTime _Birth;

        private DateTime _Death;

        private bool _Male;

        private string _Nationality;

        private string _Address;

        private string _Email;

        private string _Description;

        private bool _isDeathNull;

        private bool _isAddressNull;

        private bool _isEmailNull;

        private bool _isDescriptionNull;

        public Artistfield()
        {
            _Art_Id = 0;
            _Name = "";
            _Birth = new DateTime();
            _Death = new DateTime();
            _Male = true;
            _Nationality = "";
            _Address = "";
            _Email = "";
            _Description = "";
            _isAddressNull = true;
            _isDeathNull = true;
            _isDescriptionNull = true;
            _isEmailNull = true;
        }

        public Artistfield(int artistid, string artname, DateTime artbirth, string artnationality, bool artgen)
        {
            _Art_Id = artistid;
            _Name = artname;
            _Birth = artbirth;
            _Male = artgen;
            _Nationality = artnationality;
            _Death = new DateTime();
            _Address = "";
            _Email = "";
            _Description = "";
            _isAddressNull = true;
            _isDeathNull = true;
            _isDescriptionNull = true;
            _isEmailNull = true;
        }

        public Artistfield(int artistid, string artname, DateTime artbirth, string artnationality, bool artgen, DateTime artdeath, string artaddress, string artemail, string artdesc)
        {
            _Art_Id = artistid;
            _Name = artname;
            _Birth = artbirth;
            _Male = artgen;
            _Nationality = artnationality;
            _Death = artdeath;
            _Address = artaddress;
            _Email = artemail;
            _Description = artdesc;
            _isAddressNull = false;
            _isDeathNull = false;
            _isDescriptionNull = false;
            _isEmailNull = false;
        }

        public int Art_ID
        {
            get { return _Art_Id; }
            set { _Art_Id = value; }
        }

        public string Art_Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        public DateTime Art_Birth
        {
            get { return _Birth; }
            set { _Birth = value; }
        }

        public string Art_Nationality
        {
            get { return _Nationality; }
            set { _Nationality = value; }
        }

        public bool Artist_Gen
        {
            get { return _Male; }
            set { _Male = value; }
        }

        public DateTime Art_Death
        {
            get
            {
                if (_isDeathNull)
                    return new DateTime();
                else 
                    return _Death;
            }
            set
            {
                _Death = value;
                _isDeathNull = false;
            }
        }

        public string Art_Address
        {
            get
            {
                if (_isAddressNull)
                    return "";
                else 
                    return _Address;
            }
            set
            {
                _Address = value;
                _isAddressNull = false;
            }
        }

        public string Art_Email
        {
            get
            {
                if (_isEmailNull)
                    return "";
                else
                    return _Email;
            }
            set
            {
                _Email = value;
                _isEmailNull = false;
            }
        }

        public string Description
        {
            get
            {
                if (_isDescriptionNull)
                    return "";
                else 
                    return _Description;
            }
            set
            {
                _Description = value;
                _isDescriptionNull = false;
            }
        }

        public bool IsDeathNull
        {
            get { return _isDeathNull; }
            set { _isDeathNull = value; }
        }

        public bool IsAddressNull
        {
            get { return _isAddressNull; }
            set { _isAddressNull = value; }
        }

        public bool IsEmailNull
        {
            get { return _isEmailNull; }
            set { _isEmailNull = value; }
        }

        public bool IsDescriptionNull
        {
            get { return _isDescriptionNull; }
            set { _isDescriptionNull = value; }
        }
    }

    public class Paintingfield
    {
        private int _Paint_id;

        private int _Art_Id;

        private int _Gen_Id;

        private int _Own_Id;

        private string _Name;

        private string _Year;

        private float _Height;

        private float _Width;

        private string _Material;

        private double _Price;


        private string _Description;

        private bool _isYearNull;


        private bool _isPriceNull;

        private bool _isDescriptionNull;

        public Paintingfield()
        {
            _Paint_id = 0;
            _Art_Id = 0;
            _Own_Id = 0;
            _Gen_Id = 0;
            _Name = "";
            _Year = "";
            _Height = 0;
            _Width = 0;
            _Material = "";
            _Price = -1;

            _Description = "";
            _isDescriptionNull = true;
            _isPriceNull = true;
            _isYearNull = true;
        }

        public Paintingfield(int paintingid, int ownid, int artid, int genid, string painting_name, float paintwidth, float paintheight, string paintmaterial)
        {
            _Art_Id = artid;
            _Gen_Id = genid;
            _Own_Id = ownid;
            _Paint_id = paintingid;
            _Name = painting_name;
            _Year = "";
            _Height = paintheight;
            _Width = paintwidth;
            _Material = paintmaterial;
            _Price = -1;


            _Description = "";
            _isDescriptionNull = true;
            _isPriceNull = true;
            _isYearNull = true;
        }

        public Paintingfield(int paintingid, int ownid, int artid, int genid, string painting_name, float paintwidth, float paintheight, string paintmaterial, string paintyear, double paintprice, string desc)
        {
            _Art_Id = artid;
            _Gen_Id = genid;
            _Own_Id = ownid;
            _Paint_id = paintingid;
            _Name = painting_name;
            _Year = paintyear;
            _Height = paintheight;
            _Width = paintwidth;
            _Material = paintmaterial;
            _Price = paintprice;

            _Description = desc;
            _isDescriptionNull = false;
            _isPriceNull = false;
            _isYearNull = false;
        }

        public int Paint_ID
        {
            get { return _Paint_id; }
            set { _Paint_id = value; }
        }

        public int Own_ID
        {
            get { return _Own_Id; }
            set { _Own_Id = value; }
        }

        public int Art_ID
        {
            get { return _Art_Id; }
            set { _Art_Id = value; }
        }

        public int Gen_ID
        {
            get { return _Gen_Id; }
            set { _Gen_Id = value; }
        }

        public string Painting_Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        public string Painting_Year
        {
            get
            {
                if (_isYearNull)
                    return "";
                else 
                    return _Year;
            }
            set
            {
                _Year = value;
                _isYearNull = false;
            }
        }

        public float Height
        {
            get { return _Height; }
            set { _Height = value; }
        }

        public float Width
        {
            get { return _Width; }
            set { _Width = value; }
        }

        public string Material
        {
            get { return _Material; }
            set { _Material = value; }
        }

        public double Price
        {
            get
            {
                if (_isPriceNull)
                    return -1;
                else return _Price;
            }
            set
            {
                _Price = value;
                _isPriceNull = false;
            }
        }




        public string Description
        {
            get
            {
                if (_isDescriptionNull)
                {
                    throw new InvalidOperationException();
                }
                else return _Description;
            }
            set
            {
                _Description = value;
                _isDescriptionNull = false;
            }
        }

        public bool IsPriceNull
        {
            get { return _isPriceNull; }
            set { _isPriceNull = value; }
        }

        public bool IsYearNull
        {
            get { return _isYearNull; }
            set { _isYearNull = value; }
        }



        public bool IsDescriptionNull
        {
            get { return _isDescriptionNull; }
            set { _isDescriptionNull = value; }
        }
    }

    public class Ownerfield
    {
        private int _Own_Id;

        private string _Name;

        private DateTime _Birth;

        private bool _Male;

        private string _Nationality;

        private string _Address;

        private string _Email;

        private string _Description;

        private bool _isBirthNull;

        private bool _isAddressNull;

        private bool _isEmailNull;

        private bool _isDescriptionNull;

        public Ownerfield()
        {
            _Own_Id = 0;
            _Name = "";
            _Birth = new DateTime();
            _Male = true;
            _Nationality = "";
            _Address = "";
            _Email = "";
            _Description = "";
            _isAddressNull = true;
            _isDescriptionNull = true;
            _isEmailNull = true;
            _isBirthNull = true;
        }

        public Ownerfield(int ownid, string ownname, string ownnationality, bool owngen)
        {
            _Own_Id = ownid;
            _Name = ownname;
            _Birth = new DateTime();
            _Male = owngen;
            _Nationality = ownnationality;
            _Address = "";
            _Email = "";
            _Description = "";
            _isAddressNull = true;
            _isDescriptionNull = true;
            _isEmailNull = true;
            _isBirthNull = true;
        }

        public Ownerfield(int ownid, string ownname, DateTime ownbirth, string ownnationality, bool owngen, string ownaddress, string ownemail, string owndesc)
        {
            _Own_Id = ownid;
            _Name = ownname;
            _Birth = ownbirth;
            _Male = owngen;
            _Nationality = ownnationality;
            _Address = ownaddress;
            _Email = ownemail;
            _Description = owndesc;
            _isAddressNull = false;
            _isDescriptionNull = false;
            _isEmailNull = false;
            _isBirthNull = false;
        }

        public int Own_ID
        {
            get { return _Own_Id; }
            set { _Own_Id = value; }
        }

        public string Own_Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        public DateTime Own_Birth
        {

            get
            {
                if (_isBirthNull)
                {
                    throw new InvalidOperationException();
                }
                else return _Birth;
            }
            set
            {
                _Birth = value;
                _isBirthNull = false;
            }
        }


        public string Own_Nationality
        {
            get { return _Nationality; }
            set { _Nationality = value; }
        }

        public bool Own_Gen
        {
            get { return _Male; }
            set { _Male = value; }
        }



        public string Own_Address
        {
            get
            {
                if (_isAddressNull) throw new InvalidOperationException();
                else return _Address;
            }
            set
            {
                _Address = value;
                _isAddressNull = false;
            }
        }

        public string Own_Email
        {
            get
            {
                if (_isEmailNull) throw new InvalidExpressionException();
                else return _Email;
            }
            set
            {
                _Email = value;
                _isEmailNull = false;
            }
        }

        public string Description
        {
            get
            {
                if (_isDescriptionNull)
                {
                    throw new InvalidOperationException();
                }
                else return _Description;
            }
            set
            {
                _Description = value;
                _isDescriptionNull = false;
            }
        }

        public bool IsBirthNull
        {
            get { return _isBirthNull; }
            set { _isBirthNull = value; }
        }
        public bool IsAddressNull
        {
            get { return _isAddressNull; }
            set { _isAddressNull = value; }
        }

        public bool IsEmailNull
        {
            get { return _isEmailNull; }
            set { _isEmailNull = value; }
        }

        public bool IsDescriptionNull
        {
            get { return _isDescriptionNull; }
            set { _isDescriptionNull = value; }
        }
    }

    public class InLocationfield
    {
        private int _Paint_id;

        private string _Location;


        public InLocationfield()
        {
            _Paint_id = 0;

            _Location = "";

        }

        public InLocationfield(int paintingid, string local)
        {

            _Paint_id = paintingid;

            _Location = local;
        }


        public int Paint_ID
        {
            get { return _Paint_id; }
            set { _Paint_id = value; }
        }



        public string Location
        {
            get { return _Location; }
            set { _Location = value; }
        }


    }

    public class Collectionfield
    {
        private int _Collect_Id;

        private int _Art_Id;

        private string _Name;

        private string _List_Paint_Id;


        private bool _isNameNull;

        public Collectionfield()
        {

            _Art_Id = 0;
            _Collect_Id = 0;

            _Name = "";
            _List_Paint_Id = "";


            _isNameNull = true;

        }

        public Collectionfield(int collectid, int artid, string list_painting_id)
        {
            _Art_Id = artid;
            _Collect_Id = collectid;

            _Name = "";
            _List_Paint_Id = list_painting_id;


            _isNameNull = true;
        }

        public Collectionfield(int collectid, int artid, string list_painting_id, string name)
        {
            _Art_Id = artid;
            _Collect_Id = collectid;

            _Name = name;
            _List_Paint_Id = list_painting_id;


            _isNameNull = false;
        }


        public int Collect_Id
        {
            get { return _Collect_Id; }
            set { _Collect_Id = value; }
        }



        public int Art_ID
        {
            get { return _Art_Id; }
            set { _Art_Id = value; }
        }



        public string List_Paint_Id
        {
            get { return _List_Paint_Id; }
            set { _List_Paint_Id = value; }
        }





        public string Name
        {
            get
            {
                if (_isNameNull)
                {
                    throw new InvalidOperationException();
                }
                else return _Name;
            }
            set
            {
                _Name = value;
                _isNameNull = false;
            }
        }



        public bool IsNameNull
        {
            get { return _isNameNull; }
            set { _isNameNull = value; }
        }
    }


    
}



